package io.file;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * @author mubei
 * @date 2021/12/2
 * @description
 */
public class CreateFile {



    @Test()
    public void Test1() {
        // base 目录下
        String path = "demo01.txt";
        File file = new File(path);
        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    @Test()
    public void test2() {
        String parentPath = "D:\\date\\distable\\practice\\code\\basic\\src\\main\\java\\io\\createFile";
        String path = "demo02.txt";
        File pathFile = new File(parentPath);
        File file = new File(pathFile,path);
        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test()
    public void test3() {
        String parentPath = "D:\\date\\distable\\practice\\code\\basic\\src\\main\\java\\io\\createFile";
        String path = "demo03.txt";
        File file = new File(parentPath,path);
        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
